package com.ruoyi.system.controller;


import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.service.SellerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-01-21 13:03:43
 */
@RestController
@RequestMapping("/seller")
@RequiredArgsConstructor
public class SellerController {

    private final SellerService sellerService;

    /**
     * 列表
     *//*
    @RequestMapping("/list")
//  @RequiresPermissions("store:tstoreseller:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = storeSellerService.queryPage(params);
        return R.ok().put("page", page);
    }

    *//**
     * 审核申请
     *//*
    @PostMapping("/aduit/{status}/{id}/")
    public R checkSeller(@PathVariable("id") Long id, @PathVariable("status") int status) {
        if (status == 2) {
            storeSellerService.aduitPass(id);
            return R.ok();
        }
        storeSellerService.aduitFail(id);

        return R.ok();
    }

    *//**
     * 根据用户id查询它用的餐馆
     *//*
    @RequestMapping("/listByUserId")
    public R listByUserId() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("list", storeSellerService.listByUserId(getUserId()));
        hashMap.put("role", getUserId());
        return R.ok(hashMap);
    }

    *//**
     * 信息
     *//*
    @RequestMapping("/info/{id}")
    @RequiresPermissions("store:tstoreseller:info")
    public R info(@PathVariable("id") Integer id) {
        StoreSellerEntity tStoreSeller = storeSellerService.getById(id);
        return R.ok().put("tStoreSeller", tStoreSeller);
    }

    *//**
     * 保存
     *//*
    @NoRepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    @RequestMapping("/save")
    public R save(@RequestBody StoreSellerEntity tStoreSeller) {
        tStoreSeller.setUserId(getUserId());
        tStoreSeller.setAdminUserId(getUserId());
        storeSellerService.save(tStoreSeller);
        tStoreSeller.setSellerId(tStoreSeller.getId());
        storeSellerService.updateById(tStoreSeller);
        return R.ok();
    }

    *//**
     * 修改
     *//*
    @RequestMapping("/update")
    @RequiresPermissions("store:tstoreseller:update")
    public R update(@RequestBody StoreSellerEntity tStoreSeller) {
        storeSellerService.updateById(tStoreSeller);

        return R.ok();
    }

    */

    /**
     * 删除
     *//*
    @RequestMapping("/delete")
    @RequiresPermissions("store:tstoreseller:delete")
    public R delete(@RequestBody Integer[] ids) {
        storeSellerService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @PostMapping("/update_store_file")
    @CheckPermissons("store:tstoreseller:update")
    public R test(@RequestBody StoreSellerFileSaveOrUpdateDTO dto) {
        try {
            storeSellerService.updateStoreSellerFile(dto, getUserId());
            return R.ok();
        } catch (Exception e) {
            return R.error("请按照要求输入数据");
        }
    }*/
    @GetMapping("/poi_info_detail")
//    @SaCheckPermission("seller:poiInfo:query")
    public R getStoreFile() {
        return R.ok(sellerService.getStoreFile());
    }

    /*@PutMapping("/update_business_status/{id}")
    @CheckPermissons("store:tstoreseller:update")
    public R updateBusinessStatus(@PathVariable("id") Long id,
                                  @RequestBody Map<String, Object> params) {
        StoreSellerEntity entity = new StoreSellerEntity();
        entity.setId(id);
        entity.setBusinessStatus((Integer) params.get("businessStatus"));
        this.update(entity);
        return R.ok();
    }*/

}
